import axios from 'axios'
import { defineStore } from 'pinia'
import router from '@/router'
const userCount = defineStore('userCount', {
  state() {
    return {
      userid: 0,
      contentid: 0,
      todolist: [],/* 全部待办 */
      userInfo: [],/* 用户信息 */
      todaylist: [],/* 当天待办 */
      updatelist: [],/* 修改数据回显 */
      day: '',/* 哪天 */
      searchlist: [], /* 搜索出来的数据 */
      /* show: false, */
      dataInfo: {
        countDay: Number,
        countMonth: Number,
        countWeek: Number,
        doneDay: Number,
        doneMonth: Number,
        doneWeek: Number,
        percentDay: Number,
        percentMonth: Number,
        percentWeek: Number
      }
    }
  },
  actions: {
    getCount() {
      axios.post(`/api/content/donePercent/${this.userid}`).then(res => {
        /* console.log(res.data) */
        this.dataInfo = res.data
        /* console.log(this.dataInfo) */
        router.push('/add')
      })

    }
  },
  persist: {
    enabled: true, // 这个配置代表存储生效，而且是整个store都存储
  },
})
export default userCount